package me.sdevil507.org.mapper;

import me.sdevil507.org.dto.OrgUserParamsDto;
import me.sdevil507.org.dto.OrgUserResultDto;
import me.sdevil507.org.dto.OrgUserSimpleResultDto;
import me.sdevil507.org.po.OrgUserPo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 组织下用户[OrgUserMapper]
 *
 * @author sdevil507
 * created on 2020-06-23 20:03:45
 */
@Component
@Mapper(componentModel = "spring", nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE, uses = {OrgDeptMapper.class, OrgExpertInfoMapper.class})
public interface OrgUserMapper {

    /**
     * po => dto
     *
     * @param po 实体类
     * @return dto传输类
     */
    OrgUserResultDto po2dto(OrgUserPo po);

    /**
     * pos => dtos
     *
     * @param pos 实体类集合
     * @return dtos传输类集合
     */
    List<OrgUserResultDto> pos2dtos(List<OrgUserPo> pos);

    /**
     * po => simpleDto
     *
     * @param po po
     * @return simpleDto
     */
    OrgUserSimpleResultDto po2SimpleDto(OrgUserPo po);

    /**
     * pos => simpleDtos
     *
     * @param pos 实体类集合
     * @return simpleDtos传输类集合
     */
    List<OrgUserSimpleResultDto> pos2SimpleDtos(List<OrgUserPo> pos);

    /**
     * dto => po
     *
     * @param dto 传输类
     * @return po实体类
     */
    @Mapping(target = "locked", defaultValue = "false")
    OrgUserPo dto2po(OrgUserParamsDto dto);

    /**
     * dtos => pos
     *
     * @param dtos 传输类集合
     * @return pos实体类集合
     */
    List<OrgUserPo> dtos2pos(List<OrgUserParamsDto> dtos);

    /**
     * 使用dto更新po
     *
     * @param dto 传输类
     * @param po  实体类
     */
    void updatePoFromDto(OrgUserParamsDto dto, @MappingTarget OrgUserPo po);
}